import request from '@/utils/requist'
import CryptoJS from '@/utils/aes_util'
let url = "http://39.100.39.50:5051"
let url2 = "http://192.168.1.3:5000"

// 获取验证码
export const getyzm = ({
  mobile
}) => {
  return request({
    method: 'post',
    url: '/api/user/send_mobile_code',
    data: {
      mobile
    }
  })
}
// 验证码登录
export const gotologin = ({
  mobile,
  sms_code
}) => {
  return request({
    method: 'post',
    url: '/api/user/login_bysms',
    data: {
      mobile,
      sms_code
    }
  })
}

// // 密码登录
export const bypwdlogin = ({
  mobile,
  password
}) => {
  let param = CryptoJS.AES_Encrypt(JSON.stringify({
    mobile,
    password
  }))
  return request({
    method: 'post',
    url: '/api/user/login_bypwd',
    // urlType: 'api3',
    data: {
      param,
    }
  })
}
// export const bypwdlogin = ({
//   mobile,
//   password
// }) => {
//   return request({
//     method: 'post',
//     url: '/api/user/login_bypwd',
//     data: {
//       mobile,
//       password
//     }
//   })
// }


// 管理员登录
export const administratorlogin = ({
  name,
  password
}) => {
  let param = CryptoJS.AES_Encrypt(JSON.stringify({
    name,
    password
  }))
  return request({
    method: 'post',
    url: '/api/user/backLogin',
    data: {
      param,
    }
  })
}

//获取code值
export const login_byvx = ({ code }) => {
  return request({
    method: 'post',
    url: '/api/user/login_byvx',
    data: {
      code
    }
  })
}
//获取code值
export const binding = ({ openid,
  unionid,
  mobile,
  sms_code }) => {
  return request({
    method: 'post',
    url: '/api/user/binding',
    data: {
      openid,
      unionid,
      mobile,
      sms_code
    }
  })
}

//注册 单位
export const getorgs = () => {
  return request({
    method: 'get',
    url: '/api/user/orgs',
  })
}
// 注册
export const getregister = (form) => {
  return request({
    method: 'post',
    url: '/api/user/register',
    data: form
  })
}
// 退出登录
export const login_out = ({ token }) => {
  return request({
    method: 'post',
    url: '/api/user/login_out',
    data: { token }
  })
}

// form
// {
//   "real_name": "real_name",
//   "age": "age",
//   "sex": "sex",
//   "mobile": "mobile",
//   "sms_code": "sms_code",
//   "name": "name",
//   "password": "password",
//   "password_again": "password_again",
//   "district_name": "district_name",
//   "position": "position",
//   "unit": "unit",
//   "section": "section"
// }